
from django.contrib.auth.backends import ModelBackend

from ERP_system.utils.cache_permission import redis_storage_permissions
from .models import UserModel
class UserLoginAuth(ModelBackend):

    def authenticate(self, request, username=None, password=None, **kwargs):
        try:
            user=UserModel.objects.get(username=username)

        except:
            return None

        if user.check_password(password):
            redis_storage_permissions(user)
            return user
